package com.example;

import com.example.utils.AssertUtils;

import java.net.URL;

public class Application {

    private static ApplicationContext applicationContext;

    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    public static void run(Class<?> originClass, ApplicationType type) {
        AssertUtils.isTrue(originClass != null && type != null, "origin source is empty");
        URL resource = originClass.getClassLoader().getResource("");
        AssertUtils.isTrue(resource != null, "resource is empty");
        applicationContext = new ApplicationContext(originClass);
        if(type.equals(ApplicationType.Servlet)){
            TomcatConfig.start();
        }
    }
}
